﻿<Window x:Class="Wpf2.Views.AddProductType1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Quản lý kho - Tạo mới sản phẩm" Width="Auto"   WindowStartupLocation="CenterScreen" WindowState="Maximized">

    <StackPanel Background="#FF5C5CD6">
        <Border  Height="48" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Margin="5,5,5,0" >
            <StackPanel Orientation="Horizontal">
               
                    <Label Content="Mã SP:" Height="28"/>
               
                
                <StackPanel Orientation="Horizontal" >
                    <Grid Height="28" Margin="0,0,0,10" VerticalAlignment="Bottom">
                        <TextBox Name="txtIDPro" Background="#FF16499A" Text="" FontSize="16" HorizontalAlignment="Left" Height="28" Width="70" TextChanged="TxtIDProTextChanged" Foreground="#FFF6F6F6" PreviewKeyUp="TxtIDProPreviewKeyUp"/>
                        <ComboBox Name="cmbSearchByID" SelectionChanged="ComboBoxSelectionChanged" Visibility="Hidden"  IsTabStop="False" IsSynchronizedWithCurrentItem="True" ></ComboBox>
                    </Grid>
                    <Button x:Name="btnSearchbyid" Background="#FF0050EF"  HorizontalAlignment="Left" Margin="0,10" Click="BtnSearchbyidClick">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/Wpf2;component/Images/searchicon.png" Width="20" Height="20"/>
                        </StackPanel>
                    </Button>
                </StackPanel>
                <Label Width="100" Content="Tên SP" Height="28" RenderTransformOrigin="0.379,0.536" />
                <StackPanel Orientation="Horizontal">
                    <Grid Height="28" >
                        <TextBox x:Name="txtSearchbyName" Background="#FF16499A" Text="" FontSize="16" Height="28" TextChanged="TxtSearchbyNameTextChanged" Foreground="#FFF6F6F6" PreviewKeyUp="TxtSearchbyNamePreviewKeyUp" Margin="-53,0,0,0" />
                        <ComboBox x:Name="cmbSearchByName"  Visibility="Hidden"  IsTabStop="False" IsSynchronizedWithCurrentItem="True" SelectionChanged="CmbSearchByNameSelectionChanged" />
                    </Grid>
                    <Button x:Name="btnSearchbyName"  Background="#FF0050EF" HorizontalAlignment="Left" Width="25"  Click="BtnSearchbyNameClick" Margin="0,10">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/Wpf2;component/Images/searchicon.png" Width="20" Height="20" RenderTransformOrigin="-0.05,0.5" />
                        </StackPanel>
                    </Button>
                </StackPanel>
                <StackPanel Margin="5,0,0,0" Height="30" Width="120" Orientation="Horizontal" Background="#FF16499A" >
                    <Label Background="#FF0050EF" Foreground="White">Đá HC</Label>
                </StackPanel>
                <StackPanel Margin="5,0,0,0" HorizontalAlignment="Right"  Width="90" Height="30" Orientation="Horizontal">
                    <Button x:Name="btnAddCatalog" Click="BtnAddCatalogClick"  Width="60" Background="#16499A">
                        <TextBlock Foreground="#FFFCFCFC">Danh mục</TextBlock>
                    </Button>
                    <StackPanel Width="30" Height="30" Background="#FF0050EF">
                        <Image Source="/Wpf2;component/Images/add.png" />
                    </StackPanel>
                </StackPanel>
                <StackPanel Margin="5,0,0,0" HorizontalAlignment="Right"  Width="100" Height="30" Orientation="Horizontal">
                    <Button x:Name="btnShowUser"   Width="70" Background="#16499A" Click="BtnShowUserClick">
                        <TextBlock Foreground="#FFFCFCFC">Người dùng</TextBlock>
                    </Button>
                    <StackPanel Width="30" Height="30" Background="#FF0050EF">
                        <Image Source="/Wpf2;component/Images/user.png" />
                    </StackPanel>
                </StackPanel>
                <StackPanel Margin="5,0,0,0"  HorizontalAlignment="Right"  Width="120" Height="30" Orientation="Horizontal">
                    <Button x:Name="btnShowProductHidden" Click="BtnShowProductHiddenClick"  Width="90" Background="#16499A">
                        <TextBlock Foreground="#FFFCFCFC">Sản phẩm ẩn</TextBlock>
                    </Button>
                    <StackPanel Width="30" Height="30" Background="#FF0050EF">
                        <Image Source="/Wpf2;component/Images/hide_product.png" />
                    </StackPanel>
                </StackPanel>

            </StackPanel>
        </Border>
        <DataGrid  x:Name="dtgProduct" ItemsSource="{Binding}"  CanUserAddRows="True" AutoGenerateColumns="False"  Height="540" RowEditEnding="DtgDanhmucRowEditEnding"  AlternatingRowBackground="PaleTurquoise" LoadingRow="DtgProductLoadingRow" Margin="5,5,5,5"  ScrollViewer.CanContentScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Visible" CellEditEnding="DtgProductCellEditEnding">
            <DataGrid.RowHeaderTemplate >
                <DataTemplate>
                    <TextBlock  Width="20" Text="{Binding Header, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}, Mode=FindAncestor}}"/>
                </DataTemplate>
            </DataGrid.RowHeaderTemplate>
            <DataGrid.Columns>
                <DataGridTextColumn Header="Mã SP Auto" Width="50"  Binding="{Binding ProductIdAuto, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True" Visibility="Hidden"/>
                <DataGridTextColumn Header="Mã SP" Width="80"  Binding="{Binding ProductId, UpdateSourceTrigger=PropertyChanged}"/>
                <DataGridTextColumn Header="Tên sản phẩm" Width="100" Binding="{Binding ProductName, UpdateSourceTrigger=PropertyChanged}"/>
                <DataGridTextColumn Header="Mô tả" Width="100" Binding="{Binding ProductDescription, UpdateSourceTrigger=PropertyChanged}"/>
                <DataGridTextColumn Header="SL" Width="50" Binding="{Binding InventoryCount, UpdateSourceTrigger=PropertyChanged}"/>
                <DataGridTextColumn Header="Dài" Visibility="Hidden" Width="50" Binding="{Binding ProductWidth, UpdateSourceTrigger=PropertyChanged}"/>
                <DataGridTextColumn Header="Rộng" Visibility="Hidden" Width="50" Binding="{Binding ProductHeight, UpdateSourceTrigger=PropertyChanged}"/>
                <DataGridTextColumn Header="M2" Visibility="Hidden" Width="50" Binding="{Binding ProductM2, UpdateSourceTrigger=PropertyChanged}"/>
                <DataGridTextColumn Header="Giá lẻ" Width="100" Binding="{Binding SellPrice,UpdateSourceTrigger=PropertyChanged,StringFormat={}\{0:###\,##0\}}"/>
                <DataGridTextColumn Header="Giá sỉ" Width="100" Binding="{Binding CostPrice,UpdateSourceTrigger=PropertyChanged,StringFormat={}\{0:###\,##0\}}"/>
                <DataGridComboBoxColumn   Header="Đơn vị"  Width="100" x:Name="dtgcmbUnit" DisplayMemberPath="UnitName" SelectedValuePath="UnitID" SelectedValueBinding="{Binding UnitId,UpdateSourceTrigger=PropertyChanged}">
                </DataGridComboBoxColumn>
                <DataGridComboBoxColumn   Header="Danh mục"  Width="100" x:Name="dtgcmbCatalog" DisplayMemberPath="CatalogName" SelectedValuePath="IDCatalog" SelectedValueBinding="{Binding CatalogId,UpdateSourceTrigger=PropertyChanged}">
                </DataGridComboBoxColumn>
                <DataGridTemplateColumn>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button x:Name="btnDelete" Width="50" Background="{x:Null}" Click="BtnDeleteClick" >
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="/Wpf2;component/Images/delete.png" Width="20" Height="20"/>
                                    <TextBlock Text="Ẩn" VerticalAlignment="Center" Margin="2,0,0,0"/>
                                </StackPanel>
                            </Button>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
    </StackPanel>

</Window>
<!--done-->